﻿using MyToDo.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;

namespace BZhanHengjicvWPF.Services
{
    public class LoginService : ILoginService
    {
        private readonly HttpRestClient restClient;

        public LoginService(HttpRestClient restClient)
        {
            this.restClient = restClient;
        }
        public async Task<ApiResponse<UserDto>> LoginAsync(UserDto dto)
        {
            BaseRequest baseRequest = new BaseRequest();
            baseRequest.Method = RestSharp.Method.POST;
            baseRequest.Route = $"api/Login/Login";
            baseRequest.Parameter = dto;
            return await restClient.ExcuteAsync<UserDto>(baseRequest);
        }

        public  async Task<ApiResponse> RegisgsterAsync(UserDto dto)
        {
            BaseRequest baseRequest = new BaseRequest();
            baseRequest.Method = RestSharp.Method.POST;
            baseRequest.Route = "/api/Login/Register";
            baseRequest.Parameter = dto;
            return await restClient.ExcuteAsync(baseRequest);
        }
    }
}
